Huffman coding and decoding based upon sectioning of a Huffman coding tree

ABSTRACT

A method of decoding a bitstream encoded according to a Huffman coding tree of height H including: extracting a first codeword of H bits from the bitstream; modifying the codeword by shifting it by a first shift value; using this modified codeword to identify using at least a first data structure either a symbol or a second data structure having an associated second offset value and an associated second shift value; and if a second data structure is identified using the first data structure: modifying the codeword by subtracting the second offset value and shifting the result by the second shift value; and using this modified codeword to identify using the second data structure either a symbol or a third data structure having an associated third offset value and an associated third shift value.

This application is a 371 of PCT/IB03/04310 filed Sep. 2, 2003.

FIELD OF THE INVENTION

Embodiments of the present invention relate to Huffman encoding anddecoding. In particular they relate to improved mechanisms for encodingand decoding and an improved representation of a Huffman tree.

BACKGROUND TO THE INVENTION

In digital processing, if a message comprises a sequence of symbols,each distinct symbol can be represented as a distinct binary codeword.Huffman's algorithm uses a table of the frequencies of occurrence ofeach symbol in a message and optimizes the variable length codewordssuch that the most frequent codeword has the shortest length. Thisresults in data compression and Huffman coding is commonly used in audioand video compression coding, for example, MPEG.

“A method for the construction of minimum-redundancy codes”, by David AHuffman, Proceedings of the IRE 40 (1952) 1098-1101, introduces HuffmanCoding.

If there are nine symbols S0, S1 . . . S8 with the following respectivefrequencies of occurrence 5, 5, 6, 1, 2, 3, 16, 9, 9, then they can beencoded using the Huffman algorithm into the binary tree illustrated inFIG. 1.

The tree 10 comprises leaf nodes Si and interior nodes Fi arranged in Hlevels. Each leaf node depends from a single interior node on the nextlowest level and represents a symbol. Each interior node depends from asingle interior node on the next lowest level. The level L of a node isdefined by setting the root to level 0, and the other nodes have a levelthat is one higher that the level of the node from which it depends. Thehighest level is the height H of the Huffman tree. The symbols (i.e. theleaves of T) are labelled from left to right as S0, S1, S2 . . . S8.

The Huffman tree illustrated in FIG. 1 results in the following codingof the symbols

TABLE 1 Symbol Codeword S0 000 S1 001 S2 010 S3 01100 S4 01101 S5 0111S6 10 S7 110 S8 111

In its simplest representation, a Huffman binary tree of height H may berepresented using a word for each node of the tree. The size of such arepresentation makes it difficult to search during decoding.

“Memory efficient and high speed search Huffman coding”, by Hashemian,IEEE Trans on Comms, Vol. 43, No 10, 2576-, October 1995, reduces thestorage space required to represent a Huffman tree and increases thedecode speed using the tree. A sparse single-side growing Huffman treeis created and partitioned into smaller and less sparse clusters(sub-trees), each L levels apart. A super-tree is constructed in whicheach cluster is represented by a node. A super table specifies thesuper-tree. It specifies, for each node, the length of the clusterassociated with that node and the address of the look up table for thatcluster. A negative entry in the look-up table is a reference back tothe super-table. A positive entry indicates that a symbol has been foundand the magnitude of the entry provides the location of the symbol inmemory, the codeword and the codeword length.

In “A memory-efficient and fast Huffman decoding algorithm”, by Chen,Inform Process Lett. 69 (1999) 119-122, weight is given to a leaf nodeequal to the number of leaves in a complete tree under the node. It isdependent upon the level of the node within the tree. Every leaf node isassigned a number equal to the cumulative weight of all the leavesappearing before it and its own weight. A codeword is given anequivalent cumulative weight as if it were a node on a tree. The actualcumulative weights are searched to determine if one matches theequivalent cumulative weight. If there is a match and the weights of thematching nodes are the same, then the codeword is a leaf node of thetree (i.e. a symbol).

“An efficient decoding technique for Huffman codes”, Chowdhury et al,Inform Process Lett, 81 (2002), 305-308, truncates a Huffman tree byremoving all the leaves to improve memory use and search speed.

It would be desirable to provide an alternative representation of aHuffman binary tree and an improved Huffman decoding mechanism fordecoding a received string of binary digits.

BRIEF DESCRIPTION OF THE INVENTION

According to one embodiment of the invention there is provided a methodof decoding a bitstream encoded according to a Huffman coding tree ofheight H comprising:

-   extracting a first codeword of H bits from the bitstream;-   modifying the codeword by shifting it by a first shift value;-   using this modified codeword to identify using at least a first data    structure either a symbol or a second data structure having an    associated second offset value and an associated second shift value;    and-   if a second data structure is identified using the first data    structure:    -   modifying the codeword by subtracting the second offset value        and shifting the result by the second shift value; and    -   using this modified codeword to identify using the second data        structure either a symbol or a third data structure having an        associated third offset value and an associated third shift        value.

According to another embodiment of the invention there is provided amethod of decoding a bitstream encoded according to a Huffman codingtree of height H comprising:

-   extracting a codeword of H bits from the bitstream;-   shifting the codeword by a predetermined shift value; and-   using the modified codeword to identify a symbol using at least a    first data structure.

According to another embodiment of the invention there is provided adecoder for decoding a bitstream encoded according to a Huffman codingtree of height H comprising:

-   a memory for storing a plurality of data structures representing the    Huffman coding tree of height H including at least a first data    structure having an associated first offset value and an associated    first shift value and a second data structure having an associated    second offset value and an associated second shift value; and-   a processor operable to subtract a current offset value from a    codeword of H bits taken from the bitstream;-   shift the result by the associated shift value; and-   address the associated data structure using the result.

According to another embodiment of the invention there is provided amethod of decoding a bitstream encoded according to a Huffman codingtree of height H comprising:

-   storing a first data structure comprising a value for each possible    node at a first level of the tree;-   storing a second data structure comprising a value for each possible    node within a first sub-tree at a second, lower level of the tree;-   extracting a first codeword of H bits from the bitstream;-   converting the value of the first codeword into a first node    position within the tree at the first level of the tree; and-   accessing the first data structure to obtain the value corresponding    to the first node position, wherein that value refers to the second    data structure;-   converting the value of the first codeword into a second node    position within the first sub-tree at the second level of the tree;    and-   accessing the second data structure to obtain the value    corresponding to the second node position.

According to another embodiment of the invention there is provided amethod of decoding a codeword from a bit stream comprising:

-   receiving a representation of a Huffman tree as a plurality of    ordered data structures comprising: a first data structure    associated with an identified first level L1 of the tree and    comprising a plurality of data entries, each entry corresponding to    a node of a full tree at the identified first level and at least a    second data structure associated with an identified second level L2    of the tree and with an identified first sub-tree and comprising a    plurality of data entries, each entry corresponding to a node of the    first sub tree, when full, at the second identified level;-   obtaining a value for a first level L1 in a Huffman tree identifying    the node in the first level L1 of the tree, when full, corresponding    to the first L1 bits of the codeword;-   obtaining from the first data structure a data entry for the    identified node, that identifies a further data structure if the    identified node is an interior node and otherwise identifies a    symbol; and-   if the identified node is an interior node:    -   obtaining a value for a second level L2 in a Huffman tree, being        a higher level than the first level L1;    -   obtaining a value identifying a first sub-tree;    -   identifying the node in the second level L2 of the first        sub-tree, when full, corresponding to the first L2 bits of the        received bit stream;    -   obtaining from a further data structure a data entry for the        identified node, that identifies a further data structure if the        identified node is an interior node and otherwise identifies a        symbol.

According to another embodiment of the invention there is provided datarepresenting a Huffman coding tree comprising leaf nodes and interiornodes arranged in H levels, wherein each leaf node depends from a singleinterior node on the next lowest level and represents a symbol and eachinterior node depends from a single interior node on the next lowestlevel, the data comprising:

-   a first data structure identifying, for each of the nodes within a    first specified level of the tree, a symbol for each leaf node and a    further data structure for each interior node, including a second    data structure for a first interior node;-   at least a second data structure, identified by the first data    structure, identifying for each of the nodes within a sub-tree,    depending from the first interior node, and at a second specified    level of the tree, a symbol for each leaf node and a further data    structure for an interior node, if any; and-   data specifying at least the first level, the second level and the    first interior node.

According to another embodiment of the invention there is provided amethod of representing a Huffman binary tree comprising:

-   producing a first data structure associated with an identified first    level L1 of the tree and comprising a plurality of data entries,    each entry corresponding to a node of a full tree at the identified    first level and identifying a further data structure if that node is    an interior node and otherwise identifying a symbol; and-   producing at least a further data structure associated with an    identified second level L2 of the tree and with an identified first    sub-tree and comprising a plurality of data entries, each entry    corresponding to a node of the first sub tree, when full, at the    second identified level L2 and identifying a further data structure    if that node is an interior node and otherwise identifying a symbol.

One advantage associated with embodiments of the invention are that thetechnique utilizes the probability of occurrence of codewords. The morefrequently occurring codewords will be decoded first.

Another advantage associated with embodiments of the invention is thelow processing overhead associated with decoding—in each decodingiteration there is only a maximum of one subtraction, one shift and onecompare. The decoding can consequently be implemented very efficientlyin a digital signal processor (DSP).

Another advantage associated with embodiments of the invention is thatthe maximum search can be designed to be less than log₂ N

BRIEF DESCRIPTION OF THE DRAWINGS

For a better understanding of embodiments of the present invention andto understand how the same may be brought into effect, reference willnow be made by way of example only to the accompanying drawings inwhich:

FIG. 1 illustrates a Huffman binary tree;

FIG. 2 illustrates a device that is usable as an encoder and/or decoder;and

FIG. 3 illustrates the decoding process;

FIG. 4 illustrates another Huffman tree.

DETAILED DESCRIPTION OF EMBODIMENTS OF THE INVENTION

Coding

In this example, let there be nine symbols S0, S1 . . . S8 with thefollowing respective frequencies of occurrence 5, 5, 6, 1, 2, 3, 16, 9,9. They can be encoded using the Huffman algorithm into the binary treeillustrated in FIG. 1.

This Huffman tree can be represented as an ordered sequence of datastructures as defined below in the following look-up tables (Tables 2, 3and 4).

TABLE 2 Lookup table Offset_value Shift_value Sub_table Lookup table 0 02 0 Lookup table 1 12 0 1

TABLE 3 sub-table 0 y 0 1 2 3 4 5 6 7 symbol_locate −>S0 −>S1 −>S2−>sub-table 1 −>S6 −>S6 −>S7 −>S8

TABLE 4 sub table 1 y 0 1 2 3 symbol locate −>S3 −>S4 −>S5 −>S5

The first data structure (Table 2) is a first look-up table. Itidentifies an offset_value and shift_value pair to be used with eachidentified sub-table. In this example, it designates that a zero offsetand shift_value of 2 should be used with sub-table 0 (Table 3) and thatan offset_value of 12 and a shift_value of 0 should be used withsub-table 1 (Table 4).

The second data structure (Table 3) is a look-up table. It is addressedusing a value y and provides in return a value for symbol_locate. Thevalue for symbol_locate may either point to a symbol value or point toanother look-up table. For example, the values for y equal to 0, 1, 2,4, 5, 6, 7 respectively point to the symbols S0, S1, S2, S6, S6, S7, S8and the value for y equal to 3 points to sub-table 1 (Table 4).

The third data structure (Table 4) is a look-up table. It is addressedusing a value y and provides in return a value for symbol_locate. Thevalue for symbol_locate may either point to a symbol value or point toanother look-up table. In this example the values for y equal to 0, 1,2, 3 respectively point to the symbols S3, S4, S5, S5.

The 8-bit symbol_locate may be formatted so that its most significantbit (MSB) identifies whether it is a pointer to a symbol (MSB=0) or apointer to another look-up table (MSB=1). Bits 1-7 gives an address ofthe correct symbol or look-up table. For example, the value ofsymbol_locate in sub-table at y=3 would be 1000 0001 indicatingsub-table 1. The value of symbol_locate in sub-table 0 at y=1 would be0000 0000 indicating symbol S0 according to Table 5 below.

TABLE 5 symbol locate Symbol 0000 0000 S0 0000 0001 S1 0000 0010 S2 00000011 S3 0000 0100 S4 0000 0101 S5 0000 0110 S6 0000 0111 S7 0000 1000 S8

The creation of the above described data structures will now bedescribed. Table 6 illustrates the methodology used to create the datastructures.

In Table 6, column 1 lists in order the symbols Si for 1=0, 1, 2 . . .N−1. Column 2 list adjacent each symbol its codeword. Column 3 gives thecount value Count_(Si) for each codeword.

Count_(Si) is the value of the sequence of bits obtained by adding 1'sto the codeword for symbol Si until it has a length H. For example, thecount value for S0 is the value of 00011 (2+1), the count value of S2 isthe value of 01011 (8+2+1). Alternatively the count value Count_(Si) maybe calculated, for each symbol Si occupying a level L_(i) and a codewordof value V, as [(V+1)*2^(H−L_(i))]−1. E.g. for S3 {01100}, V=12 & L=0,and count=[(12+1)*(2^0)]−1=12 and for S8 {111}, V=7 & L=2, andcount=[(7+1)*(2^2)]−1=31.

Column 4 gives a factor for each symbol. This is calculated, for symbolSi, as count_(Si)-count_(Si-1), where count_(S-1)=−1. It mayalternatively be calculated, for Symbol Si at level L_(i), as2^(H−L_(i)).

Column 5 gives the ‘shift’ for each symbol. It is the logarithm to thebase 2 of the symbol's factor. The shift may alternatively becalculated, for each symbol Si, as L_(i).

TABLE 6 4 Fac- 5 2 tor 2{circumflex over ( )} Shift 6 7 1 Code- 3 (H − H− y = (x − y = (x − Si word Count_(Si) L_(i)) L_(i) 0) >> 2 12) >> 0 8 9S-1 −1 S0 000  3 (011) 4 2 0 (0) — S1 001  7 (111) 4 2 1 (1) — S2 010 11(1011) 4 2 2 (10) — S3 01100 12 (1100) 1 0 3 (11) 0 S4 01101 13 (1101) 10 3 (11) 1 S5 0111 15 (1111) 2 1 3 (11) 3 S6 10 23 (10111) 8 3 5 (101) —S7 110 27 (11011) 4 2 6 (110) — S8 111 31 (11111) 4 2 7 (111) —

Equation 1 is used to calculate the values in columns 6 and 7, whichprovide the content for the second and third data structures (Tables 3and 4).y=(x−offset_value)>>(shift_value)  Equation 1where

-   x is the value of a codeword, offset-value is an integer greater    than or equal to 0, and shift value is an integer greater than or    equal to 0. The operator “>>” indicates that the value    (x−offset_value) should be truncated by shift_value, losing    shift_value of its least significant bits. This shift operation to    the left is equivalent to a divide by 2^shift_value operation but is    easily performed by a digital signal processor (DSP).

For column 6 i.e. the second data structure (Table 3) the offset_valueis set to zero and the shift_value is set to 2. The equation y=(x−0)>>2is used to calculate each of the entries in column 6, which correspondto y values in sub-table 0 (Table 3). The symbols S3, S4 and S5 share acommon y value. A further sub-table is used for these symbols.

For column 7 i.e. the third data structure (Table 4) the offset_value is12 and the shift_value is set to 0. The equation y=(x−12)>>0 is used tocalculate each of the entries in column 7 for unresolved symbols S3, S4and S5, which correspond to the y values in sub-table 1 (Table 4).

Consequently, the sub-table 0 represents the nodes in the Huffman binarytree of FIG. 1 at a level Li that is shift_value levels removed from thetop of the tree i.e. Li=H− shift_value.

The nodes at L=3, in order are, S0, S1, S2, F2, empty, empty, S7, S8.The empty nodes would depend from a leaf node associated with symbol S6.The symbol S6 is therefore placed in the dependant empty nodes. Thenodes at L=3, can be re-written as S0, S1, S2, F2, S6, S6, S7, S8. Thiscorresponds to the content of the entries in sub-table 0.

The internal node F2, is the root of a sub-tree. The sub-table 1represents this sub-tree. The count value of any leaf nodes that dependfrom F2 will have values between 12 and 15. The count values of thecodewords are renormalized by subtracting 12, the offset value forsub-table 1.

The sub-table 1 represents the nodes of the sub-tree at a level L in theHuffman binary tree equal to H−shift_value. Shift_value, for sub-table1, is zero for this sub-tree so L=5.

The nodes at L=5 are, in order, S3, S4, empty, empty. The empty nodeswould depend from a leaf node associated with symbol S5. The symbol S5is therefore placed in the dependant empty nodes. The nodes at L=5 canbe rewritten as S3, S4, S5, S5. This corresponds to the content of theentries in sub-table 1.

The Huffman tree in FIG. 1 is therefore represented by a first datastructure, sub-table 0, representing the tree at level L=3 and by asecond data structure, sub-table 1, representing a sub-tree at levelL=5.

Sectioning the tree is necessary to allow the most probable symbols tobe found first in an efficient manner. However, the introduction of toomany sections uses additional memory to store the additional sub-tableand additional shift and offset values and requires additionalprocessing steps to decode the less commonly occurring symbols.

For example, it is possible to represent the Huffman tree by sectioningit at different levels than L=3 and L=5. For example, if the tree issectioned at L=3, L=4 and L=5, there will be three sub-tables. The firstentry of the sub-table for L=4 will refer to the sub-table for L=5 andthe second entry will refer to S5. The first entry of the sub-table forL=5 will refer to S3 and the second entry will refer to S4. The offsetfor both these sub-table is 12. The shift for the sub-table for L=4 is 1and the shift for the sub-table for L=5 is 0.

The following should be noted for the sectioning of the Huffman tree ofFIG. 1 that gave the data structures of Tables 2, 3, 4 and 5.

A data structure representing a level L of a tree (i.e. a tree sectionedat L) has a shift value equal to H−L. A data structure referenced from anode N in the tree, where the node N has a codeword value V and is inlevel L, has an offset_value V*2^(H−L).

For the sub-table 0, the shift value is set equivalent to H−L*, where L*is the level at which the tree is sectioned. Here it is the lowest levelon which multiple leaves appear. In FIG. 1 there is one leaf at L=2, butmultiple leaves at L=3. Therefore the tree is sectioned at L=3 and theshift_value=2. The offset_value is 0.

For example, the sub-table 1 is referenced via node {011} at L=3. V=3,therefore the offset_value for the sub-table 1 is 3*2^2. The shift valuefor the sub-table 1 is set equivalent to H−L*, where L* is the level atwhich the tree is sectioned. Here, it is the lowest level on whichmultiple leaves appear in the sub-tree. In FIG. 1 the sub-tree has asits root F2 in level L=3. This sub-tree has one leaf at L=4, but two atL=5. Therefore the tree is sectioned at L=5 and shift_value=0.

FIG. 2 illustrates a device 20 that is operable as an encoder. Theencoder device comprises a processor 22 and a memory 24. The memory 24stores computer program instructions that control the processor 22 tocarry-out the encoding process described above.

The computer program instructions may be transferred to the memory via asuitable storage medium in which the instructions are embodied or theymay be transferred via electrical signals embodying the instructions.

The processor 22 has an input 21 for receiving data for encoding and hasan output 23 for providing encoded data. The encoded data includes aplurality of data structures representing a Huffman tree and a value forthe height H of the tree.

Decoding

FIG. 2 illustrates a device 20 operable an a decoder. The decodercomprises a processor 22 and a memory 24. The memory stores datastructures representing a Huffman tree as described above. For examplethe memory 24 may store tables corresponding to those illustrated inTables 2, 3, 4 and 5 above. The memory also stores computer programinstructions that control the processor 22 to carry-out the decodingprocess described below with reference to FIG. 3.

The computer program instructions may be transferred to the memory via asuitable storage medium in which the instructions are embodied or theymay be transferred via electrical signals embodying the instructions.

The processor 22 has an input 21 for receiving data for decoding and hasan output 23 for providing decoded data. The height of the Huffman treeis known in the decoder. This may be communicated to the decoder in aheader provided with the data for decoding.

The decoder performs the following steps as illustrated in FIG. 3:

At step 100 the current sub-table identifier z is set to zero.

Then at step 102, H bits are extracted from the bitstream, having avalue x

Then at step 104, the look-up table is accessed. The offset_value andshift_value for sub-table z is obtained.

Then at step 106, calculate a y value for the current sub-table fromequation 1 using x and the obtained values of offset_value andshift_value for the current sub-table.

Then at step 108, access the current sub-table, sub-table z. Obtain thesymbol_locate from sub-table z corresponding to the calculated y value.

Then at step 110, a comparison is performed on the MSB of the obtainedsymbol_locate. If the MSB of the obtained symbol_locate is 0 then theprocess jumps to step 114 If the MSB of the obtained symbol_locate is 1,the process jumps to step 112.

At step 112, the current sub-table identifier z is set equal to theremaining least significant bits of the symbol_locate obtained at step108. Then the process returns to step 104.

At step 114, the symbol corresponding to by the symbol_locate obtainedat step 108.

An example of the process illustrated will now be given using theexample look-up tables given above (Tables 2, 3, 4 and 5). The codewordto be searched is {0, 1, 1,1 }. Let the extracted bits be {0, 1, 1, 1,0}.

At step 100, set the current sub-table indicator z=0

At step 102, extract bits {0, 1, 1, 1, 0}. Therefore x=14.

At step 104, access the look-up table (Table 2). The offset_value forsub-table 0=0 and the shift_value for sub-table 0=2.

At step 106, calculate y using equation 1.y=(x−0)>>2=3

At step 108, access the current sub-table, sub-table 0 (Table 3). Obtainthe symbol_locate from sub-table 0 corresponding to the calculated yvalue. The symbol_locate is {1000 0001}.

At step 110, the MSB of the obtained symbol_locate is determined to be1, therefore go to step 112.

At step 112, z is set equal to the remaining least significant bits {0000001} of the obtained symbol_locate i.e. z=1.

At step 104, access the current look-up table (Table 2). Obtain a newoffset_value and a new shift_value for the new current sub-table(sub-table 1). The offset_value for sub-table 1=12 and the shift_valuefor sub-table 1=0.

At step 106, calculate y for current sub-table, sub-table 1, usingequation 1.y=(x−12)>>0=2

At step 108, access the current sub-table (sub-table 1). Obtain thesymbol_locate corresponding to the new y value (y=2). The symbol_locateis {0000 0101}.

At step 110, the MSB, of the obtained symbol_locate is determined to be0, therefore go to step 114.

At step 114, obtain the symbol corresponding to the obtainedsymbol_locate. The symbol corresponding to the obtained symbol_locate{0000 0101} is, from Table 5, S5.

It will be understood that the same result will be achieved if theextracted bits are {0, 1, 1,1,1} instead of {0, 1, 1, 1, 0}.

Further Illustration

As a further illustration the encoding of the Huffman tree illustratedin FIG. 4 will now be briefly described.

Si codeword count_(Si) S0 000 15 S1 001 31 S2 010 47 S3 01100 51 S40110100 52 S5 0110101 53 S6 011011 55 S7 0111 63 S8 10 95 S9 110 111 S10111 127

Sectioning the tree at L=3, gives y=(x−0)>>4

y0 0 1 2 3 4 5 6 7 symbol_locate S0 S1 S2 Goto S8 S8 S9 S10 table1

Sectioning the tree at L=4, gives y=(x−48)>>3, where V{011}*2^4=48

y1 0 1 symbol_locate Goto table2 S7

Sectioning the tree at L=5, gives y=(x−48)>>2, where V{0110}*2^3=48

y2 0 1 symbol_locate S3 Goto table3

Sectioning the tree at L=7, gives y=(x−52)>>0, where V{01101}*2^2=52

y3 0 1 2 3 symbol_locate S4 S5 S6 S6

Although the present invention has been described with reference tovarious particular examples, it should be understood the variousvariations and modification can be made without departing from thespirit and scope of the invention.

1. A method of decoding a bitstream encoded according to a Huffmancoding tree of height H comprising: extracting a first codeword of Hbits from the bitstream; modifying the codeword by shifting it by afirst shift value; using this modified codeword to identify using atleast a first data structure either a symbol or a second different datastructure having a second offset value and a second shift value; and ifa second data structure is identified using the first data structure:modifying the codeword by subtracting the second offset value andshifting the result by the second shift value; and using this modifiedcodeword to identify using the second data structure either a symbol ora third different data structure having a third offset value and a thirdshift value.
 2. A method as claimed in claim 1, further comprisingaccessing a look-up table to obtain the first shift value and accessingthe look-up table to obtain the second offset value and the second shiftvalue.
 3. A method as claimed in claim 1, wherein the first datastructure represents a first level of the Huffman coding tree and thesecond data structure represents a second, lower level of the Huffmancoding tree.
 4. A method as claimed in claim 1, further comprisingreceiving at least a value of H, the first shift value, the secondoffset value, the second shift value, the first data structure and thesecond data structure.
 5. A method as claimed in claim 1, wherein thestep of modifying the codeword by shifting it by the first shift valuecomprises firstly subtracting a first off-set value, if any, from thecodeword and then shifting the result by the first shift value.
 6. Astorage medium or transmission medium embodying a computer program forperforming the method of claim
 1. 7. A method of decoding a bitstreamencoded according to a Huffman coding tree of height H comprising:extracting a codeword of H bits from the bitstream; modifying thecodeword by firstly subtracting a first off-set value, if any, from thecodeword to obtain a result and then shifting the result by apredetermined shift value; and using the modified codeword to identify asymbol using at least a first data structure.
 8. A method as claimed inclaim 7, further comprising accessing a look-up table to obtain thepredetermined shift value.
 9. A method as claimed in claim 7, whereinthe first data structure represents a first level of the Huffman codingtree.
 10. A method as claimed in claim 7, further comprising receivingat least the value of height H, the predetermined shift value, and thefirst data structure.
 11. A storage medium or transmission mediumembodying a computer program for performing the method of claim
 7. 12. Adecoder for decoding a bitstream encoded according to a Huffman codingtree of height H comprising: a memory for storing a plurality of datastructures representing the Huffman coding tree of height H including atleast a first data structure having an associated first offset value andan associated first shift value and a second data structure having anassociated second offset value and an associated second shift value; anda processor operable to subtract an offset value from a codeword of Hbits taken from the bitstream; shift the result by a shift value; andaddress a data structure using the shifted result.
 13. A decoder asclaimed in claim 12, wherein the first data structure represents a firstlevel of the Huffman coding tree and the second data structurerepresents a second, lower level of the Huffman coding tree.
 14. Adecoder as claimed in claim 13, wherein the first shift valuecorresponds to the first level.
 15. A decoder as claimed in claim 14,wherein the processor is operable having obtained a value fromaddressing the associated data structure, to perform a comparison usingthat value and in dependence upon the comparison either use the value toidentify a symbol or a new current offset value.
 16. A decoder asclaimed in claim 15, wherein the comparison uses the MSB of the value.17. A decoder as claimed in claim 15, wherein the current offset valueis initially set to the first offset value.
 18. A decoder as claimed inclaim 13, wherein the second shift value corresponds to the secondlevel.
 19. A decoder as claimed in claim 13 wherein the second offsetvalue identifies a position of a first sub-tree within the Huffman tree.20. A method of decoding a bitstream encoded according to a Huffmancoding tree of height H comprising: storing a first data structurecomprising a value for each possible node at a first level of the tree;storing a second data structure comprising a value for each possiblenode within a first sub- tree at a second, higher level of the tree;extracting a first codeword of H bits from the bitstream; converting avalue of the first codeword into a first node position within the treeat the first level of the tree; and accessing the first data structureto obtain the value corresponding to the first node position, whereinthat value refers to the second data structure; converting the value ofthe first codeword into a second node position within the first sub-treeat the second level of the tree; and accessing the second data structureto obtain the value corresponding to the second node position.
 21. Astorage medium or transmission medium embodying a computer program forperforming the method of claim
 20. 22. A method of decoding a codewordfrom a bit stream comprising: receiving a representation of a Huffmantree as a plurality of ordered data structures comprising: a first datastructure associated with an identified first level L1 of the tree andcomprising a plurality of data entries, each entry corresponding to anode of a full tree at the identified first level and at least a seconddata structure associated with an identified second level L2 of the treeand with an identified first sub-tree and comprising a plurality of dataentries, each entry corresponding to a node of the first sub tree, whenfull, at the second identified level; obtaining a value for a firstlevel L1 in a Huffman tree identifying the node in the first level L1 ofthe tree, when full, corresponding to the first L1 bits of the codeword;obtaining from the first data structure a data entry for the identifiednode, that identifies a further data structure or identifies a symbol;and if the data entry identifies a further data structure: obtaining avalue for a second level L2 in a Huffman tree, being a higher level thanthe first level L1; obtaining a value identifying a first sub-tree;identifying the node in the second level L2 of the first sub-tree, whenfull, corresponding to the first L2 bits of the received bit stream;obtaining from a further data structure a data entry for the identifiednode, that identifies a further data structure or identifies a symbol.23. A storage medium or transmission medium embodying a computer programfor performing the method of claim
 22. 24. Data representing a Huffmancoding tree comprising leaf nodes and interior nodes arranged in Hlevels, wherein a leaf node depends from an interior node of the nextlowest level and represents a symbol and wherein an interior nodedepends from an interior node of the next lowest level, the datacomprising: a first data structure identifying, for each of the nodeswithin a first specified level of the tree, a symbol for each leaf nodeand a further data structure for each interior node, including a seconddata structure for a first interior node; at least a second datastructure, identified by the first data structure, identifying for eachof the nodes within a sub-tree, depending from the first interior node,and at a second specified level of the tree, a symbol for each leaf nodeand a further data structure for an interior node, if any; and dataspecifying at least the first level, the second level and the firstinterior node.
 25. Data as claimed in claim 24, wherein the first datastructure identifies a symbol for each empty node, if any.
 26. Data asclaimed in claim 24, wherein the second data structure identifies asymbol for each empty node of the sub-tree at a second level of thetree.
 27. Data as claimed in claim 24, wherein the first level is thelowest level within the tree with at least two leaf nodes.
 28. Data asclaimed in claim 24, wherein the second level is the lowest level withinthe sub-tree with at least two leaf nodes.
 29. Data as claimed in claim24, wherein the first interior node, when at level L (L=0, 1, 2 . . . )and having a value V, is specifying by a value dependent uponV*2{circumflex over (0)}(H−L).
 30. Data as claimed in claim 24, furthercomprising data specifying H.
 31. A storage medium or transmissionmedium embodying the data as claimed in claim
 24. 32. A method ofrepresenting a Huffman binary tree comprising: producing a first datastructure associated with an identified first level L1 of the tree andcomprising a plurality of data entries, each entry corresponding to anode of a full tree at the identified first level and identifying afurther data structure if that node is an interior node and otherwiseidentifying a symbol; and producing at least a further data structureassociated with an identified second level L2 of the tree and with anidentified first sub-tree and comprising a plurality of data entries,each entry corresponding to a node of the first sub tree, when full, atthe second identified level L2 and identifying a further data structureif that node is an interior node and otherwise identifying a symbol. 33.A method as claimed in claim 32, running an algorithm to determine thenumber of data structures and their associated levels within the Huffmantree.
 34. A method as claimed in claim 32 further comprising identifyinga sub-tree having a root node at level L (L=0, 1, 2 . . . ) and value Vusing a value dependent upon V*2^(H−L).
 35. A decoder, comprising: meansfor storing a plurality of data structures representing a Huffman codingtree of height H including at least a first data structure having anassociated first offset value and an associated first shift value and asecond data structure having an associated second offset value and anassociated second shift value; means for subtracting an offset valuefrom a codeword of H bits taken from a bitstream to produce a result;means for shifting the result by a shift value; and means for addressinga data structure using the shifted result.
 36. The decoder of claim 35,wherein the first data structure represents a first level of the Huffmancoding tree and the second data structure represents a second, lowerlevel of the Huffman coding tree.
 37. The decoder of claim 36, whereinthe first shift value corresponds to the first level.
 38. The decoder ofclaim 36, wherein the second shift value corresponds to the secondlevel.
 39. The decoder of claim 36, wherein the second offset valueidentifies a position of a first sub-tree within the Huffman tree. 40.The decoder of claim 35, further comprising means, responsive to havingobtained a value from addressing the data structure, for comparing usingthat value and in dependence upon a result of comparing to either usethe value obtained from addressing the data structure to identify asymbol or a new current offset value.
 41. The decoder of claim 40,wherein the comparing means use a most significant bit (MSB) of thevalue.
 42. The decoder of claim 40, wherein the current offset value isinitially set to the first offset value.